﻿using System;
using System.Linq;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
//using Calendar.Web.Resources.Tooltips;

namespace Calendar.Web.Core
{
    public static class HtmlHelperExtensions
    {
        public static MvcHtmlString DisplayEnumFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
        {
            var value = expression.Compile()(html.ViewData.Model).ToString().Replace('_',' ');
            return html.Label("", value);
        }

        public static MvcHtmlString EditorEnumFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, Type eType)
        {
            var values = Enum.GetValues(eType).Cast<Enum>().ToDictionary(value => value.ToString(), value => value.ToString().Replace('_', ' '));
            return html.DropDownListFor(expression, new SelectList(values, "Key", "Value"));
        }

    }
}